package com.monitor.controller;

import com.monitor.entity.OpeningCarTire;
import com.monitor.service.ErpTireSensorService;
import com.monitor.util.Result;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/erpTireSensor")
public class ErpTireSensorController {
	@Autowired
	private ErpTireSensorService erpTireSensorService;

    @RequestMapping("/findCarDetailed")
    @ApiOperation("期初物料-车辆物料")
    @ApiImplicitParams({
           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),*/
            @ApiImplicitParam(name = "carPlate", value = "车辆牌号", required = false, dataType = "String", paramType = "query")
    })
    public Result<List<OpeningCarTire>> findCarDetailed(String carPlate){
    	return erpTireSensorService.findCarDetailed(carPlate);
    }

//    @Resource
//    private ErpInspectionContentService erpInspectionContentService;
//    @RequestMapping("/findCarDetailed")
//    @ApiOperation("期初物料-车辆物料")
//    @ApiImplicitParams({
//           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "endDate", value = "结束时间", required = false, dataType = "String", paramType = "query"),*/
//            @ApiImplicitParam(name = "carPlate", value = "车辆牌号", required = false, dataType = "String", paramType = "query")
//    })
//    public Result<List<OpeningCarTire>> findCarDetailed(String carPlate){
//
//        Result<List<OpeningCarTire>> listResult=new Result<>();
//        try{
//
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//
//        return null;
//    }

//    @Resource
//@RequestMapping("/getTireByCarId")
//@ApiOperation("统计管理-车辆物料")
//@ApiImplicitParams({
//           /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
//            @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "parentId", value = "父id", required = false, dataType = "int", paramType = "query"),*/
//        @ApiImplicitParam(name = "custId", value = "客户ID", required = false, dataType = "int", paramType = "query"),
//        @ApiImplicitParam(name = "carId", value = "车辆ID", required = false, dataType = "int", paramType = "query")
//})
//public @ResponseBody
//Result<List<Map<String,Object>>> getTireByCarId(@RequestParam(value = "carId", defaultValue = "0") Integer carId, Integer custId) {
//    Result<List<Map<String,Object>>> result=new Result<List<Map<String,Object>>>();
//    try{
//        String carIdStr=null==carId||0==carId?"":carId.toString();
//        if (StringUtils.isEmpty(carIdStr)){
//            List<ErpCustomerCar> cars=carService.selectList(new EntityWrapper<ErpCustomerCar>().eq("customer_id",custId));
//            if(0==cars.size()){
//                result.setCount(0);
//                result.setData(null);
//                result.setMsg("数据为空");
//                return result;
//            }
//            List<Integer> carIds=cars.stream().map(ErpCustomerCar::getId).collect(Collectors.toList());
//            carIdStr= BlankUtil.listToString(carIds);
//        }
//        List<Map<String, Object>> mapList= archivesService.getTireByCarId(carIdStr);
//        result.setCount(mapList.size());
//        result.setData(mapList);
//    }catch (Exception e){e.printStackTrace();}
//    return result;
//}

    @RequestMapping("/addCarDetailed")
    @ApiOperation("期初物料-车辆物料-物料添加")
    @ApiImplicitParams({
        /* @ApiImplicitParam(name = "id", value = "id", required = false, dataType = "int", paramType = "query"),
         @ApiImplicitParam(name = "name", value = "部门名称", required = false, dataType = "String", paramType = "query"),
         @ApiImplicitParam(name = "startDate", value = "开始时间", required = false, dataType = "String", paramType = "query"),*/
         @ApiImplicitParam(name = "custId", value = "客户id", required = false, dataType = "int", paramType = "query"),
         @ApiImplicitParam(name = "userId", value = "用户id", required = false, dataType = "int", paramType = "query")
 })
    public Result<Integer> addOpeningCarTire(OpeningCarTire op,int custId,int userId){
    	return erpTireSensorService.addOpeningCarTire(op, custId, userId);
    }
}
